/*
Author: Tim Nguyen
Functionality: is a child to the Facility class so that 
		the building has the ability to have people escape
Version number: 0.0.1
Testers: needs to be tested
Date written: November 13th 2011
Date tested: needs to be tested
*/

package disease;

public class Airport extends Facilities{
  private double randomNumber;
  private double infectionChance;
  private int planes = 4;
  private static boolean maxLevel = false;
  
  
  public Airport(String type,int randomNum) {
      super(type);
      randomNumber = randomNum; // a random number will be passed in 
      						  // when creating an instance of this class
      infectionChance = 1.0;    //100% if bitten will be turned to a zombie
  }
  
  public boolean upgradeAirport(){
	  if (on == true && planes < 8){
		  System.out.println("upgrade success");
		  planes += 1;
		  infectionChance -= .1;
		  super.upgradeBuilding();
		  return true;
	  }
	  else if (on == false){
		  System.out.println("airport closed, can't upgrade");
		  return false;
	  }
	  else{
		  System.out.println("Cannot upgrade further");
		  maxLevel = true;
		  return false;
	  }
  }
  
  public int peopleEscape() {
	    int savedPeople = 1;
	    	savedPeople *= planes*(int)randomNumber;
	    	infectionChance += 0.05; //higher population density
	    	savedPeople -= savedPeople*infectionChance;
	    	return savedPeople;
	    }
  
  public double getInfectionChance(){
	  return infectionChance;
  }

  public boolean canUpgrade(){
	  return !maxLevel;
  }
  public boolean getMaxLevel(){
  	return maxLevel;
  }
}